/**************************
* @Summary
* @Author 20009200303 赵传博
* @Date 2022/3/31
*****************************/

#include "ErrorUtil.h"
#include <cstdarg>

void ErrorUtil::error(const char *format, ...) {
    va_list ap;
    va_start(ap, format);
    for(int i = 0; format[i] != '\0'; ++i){
        if(format[i] == '%'){
            ++i;
            switch (format[i]) {
                case 's' : {
                    char* out = va_arg(ap, char*);
                    cout << out;
                    break;
                }
                case 'c' : {
                    char out = (char)va_arg(ap, int);
                    cout << out;
                    break;
                }
                case 'd' : {
                    int out = va_arg(ap, int);
                    cout << out;
                    break;
                }
            }
        }else{
            cout << format[i];
        }
    }
    va_end(ap);
    cerr << endl;
}
